<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .old {
            border: 1px solid #000;
        }
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
        }

        .new {
            width: 200px;
            height: 200px;
            background-color: purple;
            margin-top: 100px;
        }
    </style>
</head>
<body>
    <div class="old"></div>
    <button>按钮</button>
    <script>
        var div = document.querySelector('div');
        var btn = document.querySelector('button');

        btn.onclick = function() {
            //通过style属性来修改样式
            // div.style.width = '200px';
            // div.style.height = '200px';
            // div.style.backgroundColor = 'purple';
            // div.style.marginTop = '100px';
            // 需要注意的是： 这里如果想保留原来的类选择的效果，就需需要加上旧的类选择器， 不然会被直接覆盖
            div.className = 'old new';
        }

    </script>
</body>
</html>